cmake_minimum_required(VERSION 3.12)
project(MetricSpace)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(CMAKE_BUILD_TYPE Debug)
#set(CMAKE_BUILD_TYPE Release)

if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release)
endif ()

# 为Debug配置设置可执行文件的输出目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/bin/debug")

# 为Release配置设置可执行文件的输出目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/bin/release")

# 设置编译器标志
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra -Wpedantic -ffast-math -march=native -DNDEBUG -fopenmp")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fopenmp")
set(CMAKE_CXX_FLAGS_DEBUG "-g")

# 开启堆优化
option(PROFILE "whether starting heap profile" OFF)

find_package(TBB REQUIRED)
find_package(Boost REQUIRED COMPONENTS program_options system filesystem)
include_directories(${Boost_INCLUDE_DIR},${TBB_INCLUDE_DIRS})

# 引入头文件
include_directories(codes/metric_index)
include_directories(codes/ml_index)
include_directories(codes/utils)

file(GLOB_RECURSE LIMS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/codes/ml_index/lims/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/codes/ml_index/lims/*.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/codes/ml_index/lims/*.cpp")
add_library(LIMS STATIC ${LIMS_SRC})
set_target_properties(LIMS PROPERTIES LINKER_LANGUAGE CXX)


add_subdirectory(test)